var router = require('koa-router')({
    prefix: '/project/:id/survey'
});
var models = require('./../models');


router.get('/', function* (next) {
    var canWork = false;
    var ready = false;
    if (this.state.pipeCtrl.distHelper && this.state.pipeCtrl.tpsHelper) {
        ready = true;
        if (typeof (this.session.work) === 'undefined') {
            canWork = true;
        } else {
            canWork = !this.session.work;
        }
    }
    this.render('project.survey.jade', {
        project: this.state.project,
        canWork: canWork,
        ready: ready
    });
});

router.get('/start', function* () {
    this.state.pipeCtrl.startSurvey();
    this.session.work = true;
    this.body = true;
});

router.get('/stop', function* () {
    this.state.pipeCtrl.stopSurvey();
    this.session.work = false;
    this.body = true;
});


module.exports = router.routes();
